using System;
using UnityEngine;

[Serializable]
public class camera_control : MonoBehaviour
{
	public float speed_forward;

	public float speed_forward_max;

	public float speed_side;

	public float speed_side_max;

	public float speed_up;

	public float speed_up_max;

	public float speed_y;

	public float speed_y_max;

	public float sp_up;

	public float sp_forward;

	public float sp_side;

	public float sp_y;

	public float r;

	public float spf_t;

	public float sps_t;

	public float spu_t;

	public float spy_t;

	public bool input;

	public int turbo;

	public float speed_turbo;

	public int Gear;

	public int TurboMax;

	public float y_axis;

	public float z_axis;

	public float x_axis;

	public float z_axis_max;

	public float x_axis_max;

	public Vector3 positionOld;

	public float speed1;

	public camera_control()
	{
		speed_forward_max = 40f;
		speed_side = 40f;
		speed_side_max = 40f;
		speed_up_max = 30f;
		speed_y_max = 12f;
		sp_up = 10f;
		sp_forward = 1.5f;
		sp_side = 1.5f;
		r = 0.25f;
		Gear = 1;
		TurboMax = 100;
		z_axis_max = 20f;
		x_axis_max = 20f;
	}

	public void Awake()
	{
		spy_t = 0f;
	}

	public void Start()
	{
		speed_forward = 0f;
		speed_side = 0f;
		InvokeRepeating("speed", 0f, 0.1f);
	}

	public void Update()
	{
		r = Time.deltaTime * 5.5f / Time.timeScale;
		sp_forward = Time.deltaTime * 25f / Time.timeScale;
		sp_side = Time.deltaTime * 25f / Time.timeScale;
		sp_up = Time.deltaTime * 25f / Time.timeScale;
		sp_y = Time.deltaTime * 4f / Time.timeScale;
		Vector3 eulerAngles = transform.rotation.eulerAngles;
		z_axis = Mathf.DeltaAngle(eulerAngles.z, 0f);
		float current = 0f;
		Vector3 eulerAngles2 = transform.rotation.eulerAngles;
		x_axis = Mathf.DeltaAngle(current, eulerAngles2.x);
		float current2 = 0f;
		Vector3 eulerAngles3 = transform.rotation.eulerAngles;
		y_axis = Mathf.DeltaAngle(current2, eulerAngles3.y);
		if (UnityEngine.Input.GetKey("up"))
		{
			input = true;
			if (!(speed_forward >= speed_forward_max))
			{
				speed_forward += sp_forward;
			}
			spf_t = Time.time;
			sps_t = Time.time;
		}
		if (UnityEngine.Input.GetKey("down"))
		{
			input = true;
			if (!(speed_forward <= 0f - speed_forward_max))
			{
				speed_forward -= sp_forward;
				spf_t = Time.time;
				sps_t = Time.time;
			}
		}
		if (UnityEngine.Input.GetKey("right"))
		{
			input = true;
			if (!(speed_side >= speed_side_max))
			{
				speed_side += sp_side;
			}
			sps_t = Time.time;
			spf_t = Time.time;
		}
		if (UnityEngine.Input.GetKey("left"))
		{
			input = true;
			if (!(speed_side <= 0f - speed_side_max))
			{
				speed_side -= sp_side;
			}
			sps_t = Time.time;
			spf_t = Time.time;
		}
		if (UnityEngine.Input.GetKey("q"))
		{
			input = true;
			if (!(speed_up >= speed_up_max))
			{
				speed_up += sp_up;
			}
			spu_t = Time.time;
		}
		if (UnityEngine.Input.GetKey("z"))
		{
			if (!(speed_up <= 0f - speed_up_max))
			{
				speed_up -= sp_up;
			}
			spu_t = Time.time;
		}
		if (UnityEngine.Input.GetKey("w"))
		{
			input = true;
			if (!(speed_y >= speed_y_max))
			{
				speed_y += sp_y;
			}
			spy_t = Time.time;
		}
		if (UnityEngine.Input.GetKey("q"))
		{
			input = true;
			if (!(speed_y <= 0f - speed_y_max))
			{
				speed_y -= sp_y;
			}
			spy_t = Time.time;
		}
		if ((!(speed_forward <= 0f) && Time.time > spf_t) || turbo == 2)
		{
			speed_forward -= sp_forward / 2f;
			if (!(speed_forward >= 0f))
			{
				speed_forward = 0f;
			}
		}
		if ((!(speed_forward >= 0f) && Time.time > spf_t) || turbo == 2)
		{
			speed_forward += sp_forward / 2f;
			if (!(speed_forward <= 0f))
			{
				speed_forward = 0f;
			}
		}
		if (!(speed_side <= 0f) && !(Time.time <= sps_t))
		{
			speed_side -= sp_side / 2f;
			if (!(speed_side >= 0f))
			{
				speed_side = 0f;
			}
		}
		if (!(speed_side >= 0f) && !(Time.time <= sps_t))
		{
			speed_side += sp_side / 2f;
			if (!(speed_side <= 0f))
			{
				speed_side = 0f;
			}
		}
		if (!(speed_up <= 0f) && !(Time.time <= spu_t))
		{
			speed_up -= sp_up / 2f;
			if (!(speed_up >= 0f))
			{
				speed_up = 0f;
			}
		}
		if (!(speed_up >= 0f) && !(Time.time <= spu_t))
		{
			speed_up += sp_up / 2f;
			if (!(speed_up <= 0f))
			{
				speed_up = 0f;
			}
		}
		if (!(speed_y <= 0f) && !(Time.time <= spy_t))
		{
			speed_y -= sp_y;
			if (!(speed_y >= 0f))
			{
				speed_y = 0f;
			}
		}
		if (!(speed_y >= 0f) && !(Time.time <= spy_t))
		{
			speed_y += sp_y;
			if (!(speed_y <= 0f))
			{
				speed_y = 0f;
			}
		}
		if (!(speed_y <= -0.2f) && !(speed_y >= 0.2f) && !(Time.time <= spy_t + 0.2f))
		{
			speed_y = 0f;
		}
		float num = Mathf.Round(speed_side / 25f * 100f) / 100f;
		float num2 = Mathf.Round(speed_up / 25f * 100f) / 100f;
		float num3 = Mathf.Round(speed_forward / 25f * 100f) / 100f;
		if (num != 0f || num2 != 0f || num3 != 0f)
		{
			transform.Translate(num * Time.deltaTime * 60f, num2 * Time.deltaTime * 60f, num3 * Time.deltaTime * 60f);
		}
		input = false;
	}

	public void OnGUI()
	{
	}

	public void speed()
	{
		speed1 = Mathf.Round((transform.position - positionOld).magnitude) * 10f * 3.6f;
		positionOld = transform.position;
	}

	public void Main()
	{
		spf_t = Time.time;
		sps_t = Time.time;
		spu_t = Time.time;
	}
}
